using Core;
using UnityEngine;

namespace g_gongjianta
{
    public class Monster : Unit, IAwake<int, Vector2>
    {
        public TblMonster.Conf Conf { get; private set; }
        public MonsterMainComponent Main { get; private set; }
        
        public CharacterData Data { get; } = new();

        public void Awake(int id, Vector2 bornPos)
        {
            base.Awake();
            Conf = G.Table.GetSO<TblMonster>().Find(id);
            Debug.Assert(Conf != null);

#if UNITY_EDITOR
            gameObject.name = $"Monster_{Conf.Id}_{InstanceId}";
#endif
            var visualParam = new VisualParam
            {
                Path = Global.UNIT_PREFAB_PATH,
                Icon = Conf.Icon,
            };

            Pos = bornPos;

            Add<VisualComponent, VisualParam>(visualParam);
            Add<MonsterMoveComponent>();

            Main = Add<MonsterMainComponent>();
        }
    }
}